package com.ll.wechat.base.utils.widget;

import com.ll.wechat.R;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.PopupWindow;

/**
 * ActionBar的下拉菜单
 * 
 * @ClassName: PopWindowForActionBar
 * @author yeliangliang
 * @date 2015-8-21 下午4:27:24
 */
public class PopWindowForActionBar extends PopupWindow implements OnClickListener{
	/**
	 * 创建popWindow
	 * 
	 * @author yeliangliang
	 * @date 2015-8-21 下午4:28:19
	 * @version V1.0
	 * @return void
	 */
	private onItemClick listenerClick;
	public void initPopWindow(Context mContext,int viewId,onItemClick listener) {
		View view = LayoutInflater.from(mContext)
				.inflate(R.layout.layout_popwindow_actionbar, null);
		view.setOnClickListener(this);
		listenerClick = listener;
		PopupWindow popupWindow = new PopupWindow(view,LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
		View view1 = LayoutInflater.from(mContext)
				.inflate(viewId, null);
		popupWindow.showAtLocation(view1, Gravity.TOP|Gravity.RIGHT, 0, 150);
		
	}

	@Override
	public void onClick(View v) {
		listenerClick.click();
	}

	public interface onItemClick{
		public void click();
	}
	
}
